<template>
  <div class="admin-feedback-management">
    <!-- 页面头部 -->
    <div class="page-header">
      <div class="header-content">
        <h1 class="page-title">反馈管理</h1>
        <p class="page-subtitle">管理系统中的所有用户反馈</p>
      </div>
      <div class="header-actions">
        <el-button @click="exportData">
          <el-icon><Download /></el-icon>
          导出数据
        </el-button>
      </div>
    </div>

    <!-- 统计卡片 -->
    <el-row :gutter="20" class="stats-row">
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.total }}</div>
              <div class="stats-label">总反馈数</div>
            </div>
            <el-icon class="stats-icon"><ChatDotRound /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.unread }}</div>
              <div class="stats-label">未读反馈</div>
            </div>
            <el-icon class="stats-icon unread"><Bell /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.replied }}</div>
              <div class="stats-label">已回复</div>
            </div>
            <el-icon class="stats-icon replied"><Check /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.avgRating.toFixed(1) }}</div>
              <div class="stats-label">平均评分</div>
            </div>
            <el-icon class="stats-icon rating"><Star /></el-icon>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 搜索和筛选 -->
    <el-card class="filter-card">
      <el-form :model="filters" :inline="true" class="filter-form">
        <el-form-item label="关键词">
          <el-input
            v-model="filters.keyword"
            placeholder="搜索反馈内容、用户名"
            clearable
            style="width: 200px"
            @keyup.enter="loadFeedbacks"
          >
            <template #prefix>
              <el-icon><Search /></el-icon>
            </template>
          </el-input>
        </el-form-item>
        
        <el-form-item label="活动">
          <el-select 
            v-model="filters.activityId" 
            placeholder="选择活动" 
            clearable 
            filterable
            style="width: 200px"
          >
            <el-option 
              v-for="activity in activityOptions" 
              :key="activity.id"
              :label="activity.title" 
              :value="activity.id" 
            />
          </el-select>
        </el-form-item>
        
        <el-form-item label="反馈类型">
          <el-select v-model="filters.type" placeholder="选择类型" clearable style="width: 120px">
            <el-option label="活动反馈" value="activity" />
            <el-option label="系统建议" value="system" />
            <el-option label="问题举报" value="report" />
            <el-option label="其他" value="other" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="评分">
          <el-select v-model="filters.rating" placeholder="选择评分" clearable style="width: 100px">
            <el-option label="5星" :value="5" />
            <el-option label="4星" :value="4" />
            <el-option label="3星" :value="3" />
            <el-option label="2星" :value="2" />
            <el-option label="1星" :value="1" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="状态">
          <el-select v-model="filters.status" placeholder="选择状态" clearable style="width: 100px">
            <el-option label="未读" value="unread" />
            <el-option label="已读" value="read" />
            <el-option label="已回复" value="replied" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="反馈时间">
          <el-date-picker
            v-model="filters.dateRange"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
            style="width: 240px"
          />
        </el-form-item>
        
        <el-form-item>
          <el-button type="primary" @click="loadFeedbacks">
            <el-icon><Search /></el-icon>
            搜索
          </el-button>
          <el-button @click="resetFilters">
            <el-icon><Refresh /></el-icon>
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 反馈列表 -->
    <el-card class="table-card">
      <template #header>
        <div class="table-header">
          <div class="header-title">
            <span>反馈列表</span>
            <span class="total-count">（共 {{ pagination.total }} 条）</span>
          </div>
          <div class="header-actions">
            <el-button 
              type="primary" 
              size="small" 
              :disabled="selectedFeedbacks.length === 0"
              @click="batchMarkRead"
            >
              批量标记已读
            </el-button>
            <el-button 
              type="danger" 
              size="small" 
              :disabled="selectedFeedbacks.length === 0"
              @click="batchDelete"
            >
              批量删除
            </el-button>
          </div>
        </div>
      </template>
      
      <div v-if="loading" class="loading-container">
        <el-skeleton :rows="5" animated />
      </div>
      
      <div v-else-if="feedbacks.length === 0" class="empty-container">
        <el-empty description="暂无反馈数据" />
      </div>
      
      <div v-else>
        <el-table
          :data="feedbacks"
          @selection-change="handleSelectionChange"
          stripe
          style="width: 100%"
        >
          <el-table-column type="selection" width="55" />
          
          <el-table-column label="用户信息" width="150">
            <template #default="{ row }">
              <div class="user-info">
                <el-avatar :src="row.user.avatar" :size="32">
                  {{ row.user.realName?.charAt(0) || row.user.username?.charAt(0) }}
                </el-avatar>
                <div class="user-details">
                  <div class="user-name">{{ row.user.realName || row.user.username }}</div>
                  <div class="user-role">{{ getUserRoleText(row.user.role) }}</div>
                </div>
              </div>
            </template>
          </el-table-column>
          
          <el-table-column label="反馈内容" width="300">
            <template #default="{ row }">
              <div class="feedback-content">
                <div class="content-text">{{ row.content }}</div>
                <div v-if="row.images && row.images.length > 0" class="content-images">
                  <el-image
                    v-for="(image, index) in row.images.slice(0, 3)"
                    :key="index"
                    :src="image"
                    :preview-src-list="row.images"
                    :initial-index="index"
                    class="feedback-image"
                    fit="cover"
                  />
                  <span v-if="row.images.length > 3" class="more-images">
                    +{{ row.images.length - 3 }}
                  </span>
                </div>
              </div>
            </template>
          </el-table-column>
          
          <el-table-column prop="activity.title" label="相关活动" width="180" show-overflow-tooltip>
            <template #default="{ row }">
              {{ row.activity?.title || '-' }}
            </template>
          </el-table-column>
          
          <el-table-column label="反馈类型" width="100">
            <template #default="{ row }">
              <el-tag :type="getTypeTagType(row.type)" size="small">
                {{ getTypeText(row.type) }}
              </el-tag>
            </template>
          </el-table-column>
          
          <el-table-column label="评分" width="80">
            <template #default="{ row }">
              <div v-if="row.rating" class="rating-display">
                <el-rate
                  :model-value="row.rating"
                  disabled
                  size="small"
                  show-score
                  text-color="#ff9900"
                />
              </div>
              <span v-else>-</span>
            </template>
          </el-table-column>
          
          <el-table-column label="状态" width="80">
            <template #default="{ row }">
              <el-tag :type="getStatusType(row.status)" size="small">
                {{ getStatusText(row.status) }}
              </el-tag>
            </template>
          </el-table-column>
          
          <el-table-column prop="createdAt" label="反馈时间" width="120">
            <template #default="{ row }">
              {{ formatDate(row.createdAt, 'MM-DD HH:mm') }}
            </template>
          </el-table-column>
          
          <el-table-column label="管理员回复" width="200" show-overflow-tooltip>
            <template #default="{ row }">
              <div v-if="row.adminReply" class="admin-reply">
                <div class="reply-content">{{ row.adminReply.content }}</div>
                <div class="reply-info">
                  <span class="reply-admin">{{ row.adminReply.adminName }}</span>
                  <span class="reply-time">{{ formatDate(row.adminReply.createdAt, 'MM-DD HH:mm') }}</span>
                </div>
              </div>
              <span v-else class="no-reply">未回复</span>
            </template>
          </el-table-column>
          
          <el-table-column label="操作" width="180" fixed="right">
            <template #default="{ row }">
              <el-button type="text" size="small" @click="viewDetail(row)">
                查看
              </el-button>
              <el-button 
                v-if="row.status === 'unread'"
                type="text" 
                size="small" 
                @click="markAsRead(row)"
              >
                标记已读
              </el-button>
              <el-button 
                v-if="!row.adminReply"
                type="text" 
                size="small" 
                @click="showReplyDialog(row)"
              >
                回复
              </el-button>
              <el-button type="text" size="small" @click="deleteFeedback(row)" class="danger">
                删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        
        <!-- 分页 -->
        <div class="pagination-container">
          <el-pagination
            v-model:current-page="pagination.page"
            v-model:page-size="pagination.size"
            :total="pagination.total"
            :page-sizes="[10, 20, 50, 100]"
            layout="total, sizes, prev, pager, next, jumper"
            @size-change="loadFeedbacks"
            @current-change="loadFeedbacks"
          />
        </div>
      </div>
    </el-card>

    <!-- 反馈详情对话框 -->
    <el-dialog
      v-model="detailDialogVisible"
      title="反馈详情"
      width="800px"
    >
      <div v-if="currentFeedback" class="feedback-detail">
        <el-descriptions :column="2" border>
          <el-descriptions-item label="用户头像">
            <el-avatar :src="currentFeedback.user.avatar" :size="60">
              {{ currentFeedback.user.realName?.charAt(0) || currentFeedback.user.username?.charAt(0) }}
            </el-avatar>
          </el-descriptions-item>
          <el-descriptions-item label="反馈状态">
            <el-tag :type="getStatusType(currentFeedback.status)">
              {{ getStatusText(currentFeedback.status) }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="用户名">{{ currentFeedback.user.username }}</el-descriptions-item>
          <el-descriptions-item label="真实姓名">{{ currentFeedback.user.realName || '-' }}</el-descriptions-item>
          <el-descriptions-item label="用户角色">{{ getUserRoleText(currentFeedback.user.role) }}</el-descriptions-item>
          <el-descriptions-item label="联系邮箱">{{ currentFeedback.user.email }}</el-descriptions-item>
          <el-descriptions-item label="相关活动" :span="2">
            {{ currentFeedback.activity?.title || '无' }}
          </el-descriptions-item>
          <el-descriptions-item label="反馈类型">
            <el-tag :type="getTypeTagType(currentFeedback.type)">
              {{ getTypeText(currentFeedback.type) }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="评分">
            <div v-if="currentFeedback.rating">
              <el-rate
                :model-value="currentFeedback.rating"
                disabled
                show-score
                text-color="#ff9900"
              />
            </div>
            <span v-else>无评分</span>
          </el-descriptions-item>
          <el-descriptions-item label="反馈内容" :span="2">
            <div class="feedback-content-detail">
              {{ currentFeedback.content }}
            </div>
          </el-descriptions-item>
          <el-descriptions-item v-if="currentFeedback.images && currentFeedback.images.length > 0" label="相关图片" :span="2">
            <div class="feedback-images">
              <el-image
                v-for="(image, index) in currentFeedback.images"
                :key="index"
                :src="image"
                :preview-src-list="currentFeedback.images"
                :initial-index="index"
                class="detail-image"
                fit="cover"
              />
            </div>
          </el-descriptions-item>
          <el-descriptions-item label="反馈时间">
            {{ formatDate(currentFeedback.createdAt, 'YYYY-MM-DD HH:mm:ss') }}
          </el-descriptions-item>
          <el-descriptions-item label="最后更新">
            {{ formatDate(currentFeedback.updatedAt, 'YYYY-MM-DD HH:mm:ss') }}
          </el-descriptions-item>
          <el-descriptions-item v-if="currentFeedback.adminReply" label="管理员回复" :span="2">
            <div class="admin-reply-detail">
              <div class="reply-content">{{ currentFeedback.adminReply.content }}</div>
              <div class="reply-meta">
                <span>回复人：{{ currentFeedback.adminReply.adminName }}</span>
                <span>回复时间：{{ formatDate(currentFeedback.adminReply.createdAt, 'YYYY-MM-DD HH:mm:ss') }}</span>
              </div>
            </div>
          </el-descriptions-item>
        </el-descriptions>
      </div>
    </el-dialog>

    <!-- 回复反馈对话框 -->
    <el-dialog
      v-model="replyDialogVisible"
      title="回复反馈"
      width="600px"
      @close="resetReplyForm"
    >
      <div v-if="currentFeedback" class="reply-context">
        <div class="original-feedback">
          <h4>原反馈内容：</h4>
          <p>{{ currentFeedback.content }}</p>
        </div>
      </div>
      
      <el-form
        ref="replyFormRef"
        :model="replyForm"
        :rules="replyRules"
        label-width="80px"
      >
        <el-form-item label="回复内容" prop="content">
          <el-input 
            v-model="replyForm.content" 
            type="textarea" 
            :rows="6"
            placeholder="请输入回复内容"
            maxlength="1000"
            show-word-limit
          />
        </el-form-item>
      </el-form>
      
      <template #footer>
        <el-button @click="replyDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="submitReply" :loading="submittingReply">
          发送回复
        </el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { formatDate } from '@/utils'
import { ElMessage, ElMessageBox } from 'element-plus'
import api from '@/utils/api'
import {
  Download,
  ChatDotRound,
  Bell,
  Check,
  Star,
  Search,
  Refresh
} from '@element-plus/icons-vue'

const router = useRouter()

const loading = ref(false)
const detailDialogVisible = ref(false)
const replyDialogVisible = ref(false)
const submittingReply = ref(false)
const replyFormRef = ref()

const stats = reactive({
  total: 0,
  unread: 0,
  replied: 0,
  avgRating: 0
})

const filters = reactive({
  keyword: '',
  activityId: '',
  type: '',
  rating: null,
  status: '',
  dateRange: null
})

const pagination = reactive({
  page: 1,
  size: 20,
  total: 0
})

const feedbacks = ref([])
const selectedFeedbacks = ref([])
const currentFeedback = ref(null)
const activityOptions = ref([])

const replyForm = reactive({
  feedbackId: null,
  content: ''
})

const replyRules = {
  content: [
    { required: true, message: '请输入回复内容', trigger: 'blur' },
    { min: 10, message: '回复内容至少10个字符', trigger: 'blur' }
  ]
}

const getStatusType = (status) => {
  const typeMap = {
    unread: 'warning',
    read: 'info',
    replied: 'success'
  }
  return typeMap[status] || ''
}

const getStatusText = (status) => {
  const textMap = {
    unread: '未读',
    read: '已读',
    replied: '已回复'
  }
  return textMap[status] || status
}

const getTypeTagType = (type) => {
  const typeMap = {
    activity: 'primary',
    system: 'success',
    report: 'danger',
    other: 'info'
  }
  return typeMap[type] || ''
}

const getTypeText = (type) => {
  const textMap = {
    activity: '活动反馈',
    system: '系统建议',
    report: '问题举报',
    other: '其他'
  }
  return textMap[type] || type
}

const getUserRoleText = (role) => {
  const roleMap = {
    student: '学生',
    organizer: '组织者',
    admin: '管理员'
  }
  return roleMap[role] || role
}

const loadStats = async () => {
  try {
    const response = await api.get('/admin/feedbacks/stats')
    const data = response.data.data
    
    Object.assign(stats, data)
    
  } catch (error) {
    console.error('加载统计数据失败:', error)
  }
}

const loadActivityOptions = async () => {
  try {
    const response = await api.get('/admin/activities/options')
    activityOptions.value = response.data.data || []
  } catch (error) {
    console.error('加载活动选项失败:', error)
  }
}

const loadFeedbacks = async () => {
  try {
    loading.value = true
    
    const params = {
      page: pagination.page,
      size: pagination.size,
      ...filters
    }
    
    if (filters.dateRange && filters.dateRange.length === 2) {
      params.startDate = filters.dateRange[0]
      params.endDate = filters.dateRange[1]
    }
    
    const response = await api.get('/admin/feedbacks', { params })
    const data = response.data.data
    
    feedbacks.value = data.list || []
    pagination.total = data.total || 0
    
  } catch (error) {
    console.error('加载反馈列表失败:', error)
    ElMessage.error('加载反馈列表失败')
  } finally {
    loading.value = false
  }
}

const resetFilters = () => {
  Object.assign(filters, {
    keyword: '',
    activityId: '',
    type: '',
    rating: null,
    status: '',
    dateRange: null
  })
  pagination.page = 1
  loadFeedbacks()
}

const handleSelectionChange = (selection) => {
  selectedFeedbacks.value = selection
}

const viewDetail = async (feedback) => {
  try {
    const response = await api.get(`/admin/feedbacks/${feedback.id}`)
    currentFeedback.value = response.data.data
    detailDialogVisible.value = true
    
    // 如果是未读状态，自动标记为已读
    if (feedback.status === 'unread') {
      await markAsRead(feedback, false)
    }
  } catch (error) {
    ElMessage.error('获取反馈详情失败')
  }
}

const markAsRead = async (feedback, showMessage = true) => {
  try {
    await api.put(`/admin/feedbacks/${feedback.id}/read`)
    
    if (showMessage) {
      ElMessage.success('已标记为已读')
    }
    
    // 更新本地状态
    feedback.status = 'read'
    loadStats()
    
  } catch (error) {
    if (showMessage) {
      ElMessage.error('操作失败')
    }
  }
}

const showReplyDialog = (feedback) => {
  currentFeedback.value = feedback
  replyForm.feedbackId = feedback.id
  replyForm.content = ''
  replyDialogVisible.value = true
}

const resetReplyForm = () => {
  replyForm.feedbackId = null
  replyForm.content = ''
  if (replyFormRef.value) {
    replyFormRef.value.resetFields()
  }
}

const submitReply = async () => {
  try {
    await replyFormRef.value.validate()
    
    submittingReply.value = true
    
    await api.post(`/admin/feedbacks/${replyForm.feedbackId}/reply`, {
      content: replyForm.content
    })
    
    ElMessage.success('回复成功')
    replyDialogVisible.value = false
    loadFeedbacks()
    loadStats()
    
  } catch (error) {
    if (error.response?.data?.message) {
      ElMessage.error(error.response.data.message)
    } else {
      ElMessage.error('回复失败')
    }
  } finally {
    submittingReply.value = false
  }
}

const deleteFeedback = async (feedback) => {
  try {
    await ElMessageBox.confirm(
      `确定要删除来自 ${feedback.user.realName || feedback.user.username} 的反馈吗？此操作不可恢复。`,
      '确认删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    await api.delete(`/admin/feedbacks/${feedback.id}`)
    ElMessage.success('删除成功')
    loadFeedbacks()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('删除失败')
    }
  }
}

const batchMarkRead = async () => {
  try {
    await ElMessageBox.confirm(
      `确定要将选中的 ${selectedFeedbacks.value.length} 条反馈标记为已读吗？`,
      '确认批量标记已读',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'info'
      }
    )
    
    const ids = selectedFeedbacks.value.map(feedback => feedback.id)
    await api.put('/admin/feedbacks/batch-read', { ids })
    
    ElMessage.success('批量标记已读成功')
    loadFeedbacks()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('批量标记已读失败')
    }
  }
}

const batchDelete = async () => {
  try {
    await ElMessageBox.confirm(
      `确定要删除选中的 ${selectedFeedbacks.value.length} 条反馈吗？此操作不可恢复。`,
      '确认批量删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    const ids = selectedFeedbacks.value.map(feedback => feedback.id)
    await api.delete('/admin/feedbacks/batch', { data: { ids } })
    
    ElMessage.success('批量删除成功')
    loadFeedbacks()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('批量删除失败')
    }
  }
}

const exportData = async () => {
  try {
    const response = await api.get('/admin/feedbacks/export', {
      params: filters,
      responseType: 'blob'
    })
    
    const blob = new Blob([response.data], {
      type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    })
    
    const url = window.URL.createObjectURL(blob)
    const link = document.createElement('a')
    link.href = url
    link.download = `反馈数据_${formatDate(new Date(), 'YYYY-MM-DD')}.xlsx`
    link.click()
    
    window.URL.revokeObjectURL(url)
    ElMessage.success('导出成功')
    
  } catch (error) {
    ElMessage.error('导出失败')
  }
}

onMounted(() => {
  loadStats()
  loadActivityOptions()
  loadFeedbacks()
})
</script>

<style scoped>
.admin-feedback-management {
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  color: white;
}

.header-content {
  flex: 1;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.page-subtitle {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 12px;
  margin-left: 20px;
}

.stats-row {
  margin-bottom: 24px;
}

.stats-card {
  cursor: pointer;
  transition: transform 0.3s ease;
}

.stats-card:hover {
  transform: translateY(-2px);
}

.stats-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.stats-info {
  flex: 1;
}

.stats-number {
  font-size: 24px;
  font-weight: 700;
  color: #303133;
  margin-bottom: 4px;
}

.stats-label {
  font-size: 14px;
  color: #909399;
}

.stats-icon {
  font-size: 28px;
  opacity: 0.3;
  color: #409eff;
}

.stats-icon.unread {
  color: #e6a23c;
}

.stats-icon.replied {
  color: #67c23a;
}

.stats-icon.rating {
  color: #ff9900;
}

.filter-card,
.table-card {
  margin-bottom: 20px;
}

.filter-form {
  margin-bottom: 0;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #303133;
}

.total-count {
  font-size: 12px;
  color: #909399;
  font-weight: normal;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.loading-container,
.empty-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-size: 13px;
  color: #303133;
  font-weight: 600;
}

.user-role {
  font-size: 12px;
  color: #909399;
}

.feedback-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content-text {
  font-size: 13px;
  color: #303133;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.content-images {
  display: flex;
  gap: 4px;
  align-items: center;
}

.feedback-image {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
}

.more-images {
  font-size: 12px;
  color: #909399;
}

.rating-display {
  display: flex;
  align-items: center;
}

.admin-reply {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reply-content {
  font-size: 13px;
  color: #303133;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reply-info {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #909399;
}

.no-reply {
  font-size: 12px;
  color: #c0c4cc;
}

.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.feedback-detail {
  max-height: 600px;
  overflow-y: auto;
}

.feedback-content-detail {
  line-height: 1.6;
  color: #303133;
}

.feedback-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-image {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  cursor: pointer;
}

.admin-reply-detail {
  background: #f5f7fa;
  padding: 12px;
  border-radius: 4px;
}

.reply-meta {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: #909399;
}

.reply-context {
  margin-bottom: 20px;
  padding: 16px;
  background: #f5f7fa;
  border-radius: 4px;
}

.original-feedback h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: #303133;
}

.original-feedback p {
  margin: 0;
  line-height: 1.6;
  color: #606266;
}

.danger {
  color: #f56c6c !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .header-actions {
    margin-left: 0;
    flex-direction: column;
  }
  
  .filter-form {
    flex-direction: column;
  }
  
  .filter-form .el-form-item {
    margin-right: 0;
    margin-bottom: 16px;
  }
  
  .table-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .header-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .user-info {
    flex-direction: column;
    gap: 4px;
  }
  
  .feedback-content {
    max-width: 200px;
  }
}
</style>